// 设置Axios拦截器,请求头,token,域名
import axios from 'axios'
// Vuex
// import store from '../store'
const request = axios.create({
  timeout: 20000
})
// Axios拦截器
request.interceptors.request.use((config) => {
  // console.log(baseUrl)
  // 域名头设置
  config.baseURL = 'http://192.168.31.156:9362'
  // 读取存储的token
  // const { user } = store.state
  const user = JSON.parse(localStorage.getItem('userData'))
  if (user && user.TOKEN) {
    // 请求头添加Token
    config.headers.TOKEN = user.TOKEN
  }
  return config
})
export default request
